<?php

class users_model extends CI_Model 
{
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
	
	// Get all users from tbl_user
	function getAllUsers( )
	{
		return $this->db->get('tbl_users');
	}
	
	// Get User based on Username and Password
	function getUserByUsernameAndPassword( $username, $password )
	{
		$this->db->where('username', $username);
		$this->db->where('password', $password);
		$this->db->from('tbl_users');
		return $this->db->get();
	}
	
	function getUserByUsername( $username )
	{
		$this->db->where('username', $username);
		$this->db->from('tbl_users');
		return $this->db->get();
	}
	
	// Updates volumes based on Access ID
	function updateUser( $username, $data_array )
	{
		$update_where = array('username' => $username);
	
		$this->db->update('tbl_users', $data_array, $update_where); 
	}
	
	// Add User
	function addUser( $data_array )
	{
		$this->db->insert('tbl_users', $data_array); 
	}
	
	// Delete user based on Username
	function deleteUser( $username )
	{
		$delete_where = array('username' => $username );
	
		$this->db->delete('tbl_users', $delete_where );
	}
}

?>